package com.tbit.main.service;

import com.tbit.main.pojo.AccountUser;
import com.tbit.main.pojo.VO.WorkOrderFinishingCountRespVO;
import com.tbit.main.pojo.VO.WorkOrderFinishingQueryReqVO;
import com.tbit.main.pojo.WorkOrder;
import com.tbit.main.pojo.WorkOrderFinishing;
import com.tbit.main.pojo.WorkOrderSta;

import java.util.List;

/**
 * @author LMY
 * @create 2021-05-18 15:38
 * 工单
 */
public interface WorkOrderFinishingService {

    /**
     * 创建工单
     *
     * @param workOrder
     */
    void insert(WorkOrder workOrder);

    /**
     * 根据运营区域查询
     *
     * @param accountId
     * @return
     */
    List<WorkOrderFinishing> getByAccountId(Integer accountId);

    /**
     * 根据运营区域查询
     *
     * @param accountId
     * @return
     */
    List<WorkOrderFinishing> getByAccountIdAndWorkType(Integer accountId, Integer workType, Integer socLimit);

    /**
     * 删除
     *
     * @param workOrderId
     */
    void del(String workOrderId);

    /**
     * 修改工单状态
     *
     * @param workOrderId
     * @param accountUserId
     * @param accountUserName
     * @param state
     */
    void updateState(String workOrderId, Integer accountUserId, String accountUserName, Integer state);

    /**
     * 根据工单编号查询
     *
     * @param workOrderId
     * @return
     */
    WorkOrderFinishing getByWorkOrderId(String workOrderId);


    /**
     * 根据运营区域和时间查询工单
     *
     * @return
     */
    List<WorkOrderFinishing> getByAccountIdUserId(Integer accountId, AccountUser accountUser,
                                                  String startTime, String endTime, Integer state, Integer workType);

    /**
     * 查询未完成工单总数
     *
     * @param accountId
     * @param accountUser
     * @param state
     * @param workType
     * @param startTime
     * @param endTime
     * @return
     */
    Integer getByUserIdCount(Integer accountId, AccountUser accountUser, String startTime, String endTime, Integer state, Integer workType);

    /**
     * 根据用户和时间查询工单分组
     *
     * @return
     */
    List<WorkOrderSta> getGroupByUserId(Integer accountId, Integer userType, Integer accountUserId,
                                        String startTime, String endTime, Integer state, Integer workType, List<Integer> regionId, Integer isValid);

    /**
     * 根据用户和时间查询工单
     *
     * @return
     */
    List<WorkOrderFinishing> getByUserId(Integer accountId, AccountUser accountUser, Integer userMainId,
                                         Integer state, Integer workType, List<Integer> regionId, Integer machineType, Integer buildType, Integer locationType);

    /**
     * 根据车辆编号和类型查询和区域
     *
     * @param machineId
     * @param workType
     * @return
     */
    WorkOrderFinishing getByMachineIdWorkType(Integer machineId, Integer workType, Integer accountId);

    /**
     * 根据车辆编号和类型查询
     *
     * @param machineId
     * @return
     */
    List<WorkOrderFinishing> getByMachineId(Integer machineId);

    /**
     * 查询失效的
     *
     * @param buildTime
     * @return
     */
    List<WorkOrderFinishing> getByBuildTime(String buildTime);

    /**
     * 查询超时
     *
     * @param getTime
     * @return
     */
    List<String> getByGetTime(String getTime);

    /**
     * 批量删除
     *
     * @param workOrderIds
     */
    void delWorkOrderIds(List<String> workOrderIds);

    /**
     * 根据工单类型查询设备id
     *
     * @param workType
     * @return
     */
    List<Integer> getByWorkType(Integer workType);

    /**
     * 更新
     *
     * @param workOrder
     */
    void update(WorkOrder workOrder);

    /**
     * 批量删除
     *
     * @param workOrderIds
     */
    void delBatch(List<String> workOrderIds);

    /**
     * 获取所有
     *
     * @return
     */
    List<WorkOrderFinishing> getAll();

    /**
     * 根据车辆类型，车辆，状态查询
     *
     * @param workType
     * @param machineId
     * @param state
     * @return
     */
    WorkOrderFinishing getByWorkMachineIdState(Integer workType, Integer machineId, Integer state);

    /**
     * 根据车辆类型，车辆，状态查询
     *
     * @param machineId
     * @param state
     * @return
     */
    List<WorkOrderFinishing> getByWorkMachineIdState(Integer machineId, Integer state);

    /**
     * 根据运维人员id和工单类型查询
     *
     * @param mainUserId
     * @param workType
     * @return
     */
    Integer getUserIdWorkType(Integer mainUserId, Integer workType);

    /**
     * 获取待办工单列表
     * @param reqVO 待办工单查询 ReqVO
     * @return 待办工单列表
     */
    List<WorkOrderFinishing> getWorkOrderFinishingList(WorkOrderFinishingQueryReqVO reqVO);

    /**
     * 根据已有的待办工单的类型进行分组统计数量
     * @param workOrderFinishingCountAll 全部工单
     * @param workOrderFinishingList 待办工单列表
     * @return 待办工单分组后数量
     */
    WorkOrderFinishingCountRespVO getWorkOrderFinishingCount(WorkOrderFinishingCountRespVO workOrderFinishingCountAll, List<WorkOrderFinishing> workOrderFinishingList);

    /**
     * 根据运维人员id和工单类型查询和位置类型
     * @param mainUserId 运维人员编号
     * @param workType 工单类型
     * @param locationType 位置类型
     * @return
     */
    Integer getUserIdWorkTypeLocationType(Integer mainUserId, Integer workType, Integer locationType);
}
